package org.hnsd.train.pattern.proxy;

/**
 * @author youqd
 * @tag.date 2023-11-01 11:20
 **/
public class Proxy extends Subject{
    private RealSubject realSubject;

    @Override
    public void request() {
        if (realSubject == null){
            realSubject = new RealSubject();
        }
        preRequest();
        realSubject.request();
        postRequest();
    }

    private void preRequest(){
        System.out.println("Proxy preRequest");
    }

    private void postRequest(){
        System.out.println("Proxy postRequest");
    }

    public static void main(String[] args) {
        new Proxy().request();
    }
}
